<?php
/**
 * Created by PhpStorm.
 * User: sunku
 * Date: 2017/12/25
 * Time: 10:05
 */

namespace Admin\Transformer;
use Common\ORG\Util\Transformer;

class OrderTransformer extends Transformer
{
    public function transformer($item) {
        $statusList = C('ORDER_STATUS');
        $typeList = C('CUSTOMER_TYPE');
        return [
            'order_id' => intval($item['id']),
            'order_code' => strval($item['order_code']),
            'admin_id' => intval($item['admin_id']),
            'department_id' => intval($item['department_id']),
            'customer_id' => intval($item['customer_id']),
            'contact_info' => isset($item['contact_info'])?$item['contact_info']:[],
            'name' => strval($item['name']),
            'mobile' => trim(strval($item['mobile'])),
            'agent_name' => strval($item['agent_name']),
            'company_name' => strval($item['company_name']),
            'ditch_company' => strval($item['ditch_company']),
            'schedule_remark' => strval($item['schedule_remark']),
            'account_company' => strval($item['account_company']),
            'admin_name' => $item['admin_name']?strval($item['admin_name']):'',
            'department_name' => $item['department_name']?strval($item['department_name']):'',
            'amount' => $item['amount']?floatval($item['amount']):0.00,
            'quoted_price' => $item['quoted_price']?floatval($item['quoted_price']):0.00,
            'base_price' => $item['base_price']?floatval($item['base_price']):0.00,
            'profit_price' => $item['profit_price']?floatval($item['profit_price']):0.00,
            'other_price' => $item['other_price']?floatval($item['other_price']):0.00,
            'recharge_price' => $item['recharge_price']?floatval($item['recharge_price']):0.00,
            'user_name' =>  strval($item['user_name']),
            'contract_number' => strval($item['contract_number']),
            'director_review' => intval($item['director_review']),
            'director_reason' => strval($item['director_reason']),
            'g_manager_review' => intval($item['g_manager_review']),
            'g_manager_reason' => strval($item['g_manager_reason']),
            'dp_manager_review' => intval($item['dp_manager_review']),
            'dp_manager_reason' => strval($item['dp_manager_reason']),
            'protocol_number' => strval($item['protocol_number']),
            'product_name' => isset($item['product_name'])?strval($item['product_name']):'',
            'customer_type' => isset($item['customer_type'])?$typeList[$item['customer_type']]:'',
            'item_num' => isset($item['item_num'])?strval($item['item_num']):0,
            'status' => intval($item['status']),
            'status_desc' => $statusList[$item['status']],
            'rebate' => intval($item['rebate']),
            'create_time' => date('Y-m-d', $item['create_time']),
            'update_time' => date('Y-m-d', $item['update_time']),
            'forecast_time' => $item['forecast_time']?date('Y-m-d', $item['forecast_time']):'',
            'itemList' => isset($item['itemList'])?$item['itemList']:[],
            'first_name' => isset($item['first_name'])?$item['first_name']:'',
            'category_name' => isset($item['category_name'])?$item['category_name']:'',
            'is_pay' => intval($item['is_pay']),
            'is_bill' => $item['is_bill'],
            'is_filing' => intval($item['is_filing']),
            'pay_amount' => floatval($item['pay_amount']),
            'pay_company' => strval($item['pay_company']),
            'pay_time' => $item['pay_time']?date('Y-m-d',$item['pay_time']):'',
            'pay_interval' => intval($item['pay_interval']),
            'remark' => trim(strval($item['remark'])),
            'deal_time' => date('Y-m-d H:i:s', $item['update_time']),
            'order_time' => $item['order_time']?date('Y-m-d', $item['order_time']):'',
           'refuse_quote_reason' => trim(strip_tags($item['refuse_quote_reason'])), //驳回报价原因
            'refuse_phase_reason' => trim(strval($item['refuse_phase_reason'])),//驳回排期原因
            'refuse_accept_reason' => trim(strval($item['refuse_accept_reason'])),//拒绝受理原因
            'phase_remark' => trim(strval($item['phase_remark'])),
            'quote_remark' => trim(strval($item['quote_remark'])),
        ];
    }
}